#include "OpenGLContext.h"
#include "Fysics/System/Base.h"
#include "Fysics/Dependencies.h"

#include <GLFW/glfw3.h>
#include <glad/glad.h>
#include <gl/GL.h>

namespace Fysics
{
	OpenGLContext::OpenGLContext(GLFWwindow* windowHandle) 
		: m_WindowHandle(windowHandle)
	{
		FAR_ASSERT(windowHandle, "Window handle is null")
	}

	void OpenGLContext::Init()
	{
		glfwMakeContextCurrent(m_WindowHandle);
		int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
		FAR_ASSERT(status, "Failed to initialize GLAD!")
		//std::cout << glGetString(GL_VENDOR) << std::endl;
	}

	void OpenGLContext::SwapBuffers()
	{	
		glfwSwapBuffers(m_WindowHandle);
	}
}